/**
 * This controller manages the User details view which are added as tabs (so multiple
 * instances are created). Each instance of the view creates an instance of this class to
 * control its behavior.
 */
Ext.define('DCApp.view.attach.DetailController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.attachdetail',

    requires: [
        'Ext.window.Toast'
    ],
    onBackClick: function() {
    	Ext.util.History.back();
    },    
    onSaveClick: function() {
        var form = this.lookupReference('form'),
        rec;
    
    if (form.isValid()) {
        rec = this.getViewModel().get('theObj');
        Ext.Msg.wait('保存', '保存附件中...');
        rec.save({
            scope: this,
            callback: this.onComplete
        });
    	}
    },

    onComplete: function() {
        Ext.Msg.hide();
        Ext.toast({
            title: '保存',
            html: '附件保存完成',
            align: 't',
            bodyPadding: 10
        });
        this.redirectTo("attachlist");
    }
});
